const mongoose = require('mongoose')

const Image = mongoose.model('Image')


const popular = () =>
  Image.find({},{filename:1,_id:0}).sort({likes:-1}).limit(1)
  .then(([res]) => ({
      filename: res ? res.filename : null,
      _id:res ? res._id: null
  }))


module.exports = popular
